<%@ page language="java" contentType="text/html; charset=UTF-8" isELIgnored="false"
    pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>请求代理日志视图</title>
<%@ include file="/base/base.jsp" %>

<style type="text/css">
	.btn_a{
		display:block;
		float:left;
		width:50px;
		height:20px;
		background: #5CACEE;
		border:1px solid black;
		cursor: pointer;
		margin-right:3px;
		color:black;
	}
	.btn_a:HOVER{
		background:#7EC0EE;
		
	}
	
	input[type='text']{
		height:23px;
	}
	select{
		height:23px;
	}
	
	#result_table,#result_table tr,#result_table td{
		border-color: #D2D2D2;
	}
</style>

<script type="text/javascript">
//表格列数据
var columns=[
	{display:"序号",width:80,render:function(rowData,rowIndex){
		return (parseInt(this.get("page"))-1)*parseInt(this.get("pageSize"))+rowIndex+1;
	}},
	{display:"渠道代码",name:"channelCode",width:130},
	{display:"渠道名称",name:"channelName",width:130},
	{display:"创建时间",name:"createTimeStr",width:130},
	{display:"IP",width:130,name:"ip",render:function(data){
		var html = "<font ";
		if(data.ips == undefined||data.ips == null){
			html = html +"></font>";
		}else if(data.ips.indexOf(',')!=-1){
			html = html+"title= '";
			var ips = data.ips.split(',');
			for(var i =0 ;i<ips.length;i++){
				html = html + ips[i]+"&#10;";
			}
			var showCell = "";
			if(data.ips.length>10){
				showCell = data.ips.substring(0,10)+"..";
			}
			html = html + "'>"+showCell+"</font>";
		}else{
			html = html +">"+data.ips+"</font>";
		}
		return html;
	}},
	{display:"响应时间",name:"responseTime",width:130,render:function(rowData){
		return (rowData.reponseTime+" ms")
	}},
	{display:"信息",name:"message",width:250}
];







$(function(){
	initTime();
	initGrid();
	realTimesearch();
});
//初始化日期时间
function initTime(){
	var now=new Date();
	var year=now.getFullYear();
	var month=now.getMonth()+1;
	month=month<10?"0"+month:month+"";
	var date=now.getDate();
	date=date<10?"0"+date:date+"";
	var hour=now.getHours();
	hour=hour<10?"0"+hour:hour+"";
	var minute=now.getMinutes();
	minute=minute<10?"0"+minute:minute+"";
	var second=now.getSeconds();
	second=second<10?"0"+second:second+"";
	var start=year+"-"+month+"-"+date+" "+(hour-1)+":"+minute+":"+hour;
	var end=year+"-"+month+"-"+date+" "+hour+":"+minute+":"+hour;
	$("#startTime").val(start);
	$("#endTime").val(end);
	
}

function initGrid(){
	var url="<%=request.getContextPath()%>/pools/applyIpLog/search.action";
	$("#ressult_div").ligerGrid({
		height:'100%',
		width:'100%',
		columns:columns,
		enabledSort:false,
		pageSize:50,
		root:"result",//数据集合
		record:"dataSize",//总数据数
		pageParmName:"pageIndex",//页索引
		pagesizeParmName:"pageLen",//页长
		usePager:true,
		dataAction:"server",
		method:"post",
		delayLoad:true,//初始化不加载
		pageSizeOptions:[20,50,100,200],
		url:url
	
	});
	var manager = $("#ressult_div").ligerGetGridManager(); 
	manager.set("height","100%");
}


function realTimesearch(){
	var ipReg=/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
	if($.trim($("#ips").val())!="" && !ipReg.test($("#ips").val())){
		alert("请输入正确格式的ip");
		return;
	}
	
	var url="<%=request.getContextPath()%>/pools/applyIpLog/search.action";
	var manager = $("#ressult_div").ligerGetGridManager(); 
    manager.set("newPage",1);
    //alert($('#realTimeSearch_form').serialize());
    //manager.set("data",$('#realTimeSearch_form').serialize());
    //manager.loadServerData($('#realTimeSearch_form').serialize()); 
	manager.set("url",url+"?"+$('#realTimeSearch_form').serialize());
}

function resetSearch(){
	$("#ips").val("");
	$("#startTime").val("");
	$("#endTime").val("");
	$("#channelCode").val("");
	$("#state").val("");
}

</script>
</head>
<body>

<div class="main main_max"  style="height:100%">
	<div class="form_body">
		<div class="form_body_tltle">申请ip日志视图</div>
		<form id="realTimeSearch_form">
		<table id="result_table" class="form_table">
			<tr style="height:40px; width:100%;" >
				<td width="18%">IP&nbsp;&nbsp;<input type="text" name="vo.applyLog.ips" id="ips"/></td>
				<td width="38%">创建时间&nbsp;&nbsp;
					<input type="text"
					onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'});"
					readonly="readonly" id="startTime" name="vo.beginTime"
					/>
					&nbsp;至
					<input type="text" 
					onfocus="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm:ss'});"
					readonly="readonly" id="endTime" name="vo.endTime"
					/>
				</td>
				<td width="18%">检索渠道&nbsp;&nbsp;
					<select id="channelCode" name="vo.applyLog.channelCode">
						<option value="">-- 全部 --</option>
						<s:iterator value="vo.channels" var="cur">
							<option value="${cur.code }">${cur.name }</option>
						</s:iterator>
					</select>
				</td>
				<td width='14%' >状态&nbsp;&nbsp;
					<select id="state" name="vo.applyLog.state">
							<option value="">-- 全部 --</option>
						<option value='1'>成功</option>
						<option value='0'>失败</option>
					</select>
				</td>
				<td width="12%" style="padding-left:3px;">
				<!--  
					<a class="btn_a" href="javascript:void(0)" onclick="realTimesearch()">查询</a>
					<a class="btn_a" href="javascript:void(0)" onclick="resetSearch()">重置</a>
				-->
  
				    <input type="button"  id="" value="查询" class="" onclick="realTimesearch()"/>
					<input type="button"  id="" value="重置" class="" onclick="resetSearch()"/>
				
				</td>
			</tr>
		</table>
		</form>
	</div>
	<div style="height:30px"></div>
	<div id="ressult_div" style="height:100%"><span/></div>
</div>
</body>
</html>